﻿using UnityEngine;
using UnityEngine.Events;

/// <summary>
/// This class is used for Events that have no arguments (Example: Exit game event)
/// </summary>
[CreateAssetMenu(menuName = "Events/Int Event Channel")]
public class IntEventChannelSO : EventChannelSO<int>
{
}


/// <summary>
/// 注意 委托持续性,so的持久性会保留没及时删除的委托影响下次进入游戏调试
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class EventChannelSO<T> : DescriptionBaseSO
{
    public UnityAction<T> OnEventRaised { get; set; }
#if UNITY_EDITOR && ODIN_INSPECTOR
    [Sirenix.OdinInspector.Button]
#endif
    public void RaiseEvent(T value)
    {
        if (OnEventRaised != null)
            OnEventRaised.Invoke(value);
    }
}